package generics

import (
	"golang.org/x/exp/constraints"
	"reflect"
)

func InArray(element interface{}, slice interface{}) bool {
	if reflect.TypeOf(slice).Kind() != reflect.Slice {
		panic("reflect: InSlice of non-slice type")
	}

	n := reflect.ValueOf(slice).Len()
	for i := 0; i < n; i++ {
		if reflect.ValueOf(slice).Index(i).Interface() == reflect.ValueOf(element).Interface() {
			return true
		}
	}

	return false
}

func inArray[T constraints.Ordered](e T, es []T) bool {
	for _, v := range es {
		if v == e {
			return true
		}
	}
	return false
}

type SumType interface {
	~int64 | ~float64
}

func Sum[K comparable, V SumType](m map[K]V) {
}
